package com.example.radioclub;

import com.example.radioclub.data.Constants;
import com.example.radioclub.login.LoginActivity;
import com.example.radioclub.music.MusicActivity;
import com.example.radioclub.music.SampleListActivity;
import com.example.radioclub.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

/**
 * This class is the first thing you see in application. This class provides
 * login options. Logins are defined in four main class which will be called
 * as Activity for Result from here.
 * 
 * @author wizard
 *
 */
public class MainPageActivity extends Activity implements OnClickListener {
	private final String TAG = Constants.APP_TAG + getClass().getName();

	private final int FACEBOOK_LOGIN = Constants.FACEBOOK_LOGIN;
	private final int GOOGLE_LOGIN = Constants.GOOGLE_LOGIN;
	private final int MSN_LOGIN = Constants.MSN_LOGIN;
	private final int YAHOO_LOGIN = Constants.YAHOO_LOGIN;

	private Button facebookLoginButton;
	private ImageButton googleLoginButton;
	private ImageButton yahooLoginButton;
	private ImageButton msnLoginButton;
	private TextView loginStatus;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.i(TAG, "starts application");
		setContentView(R.layout.activity_main_page_layout);
		this.facebookLoginButton = (Button) findViewById(R.id.facebook_login_btn);
		this.facebookLoginButton.setOnClickListener(this);
		this.googleLoginButton = (ImageButton) findViewById(R.id.google_login_btn);
		this.googleLoginButton.setOnClickListener(this);
		this.yahooLoginButton = (ImageButton) findViewById(R.id.yahoo_login_btn);
		this.yahooLoginButton.setOnClickListener(this);
		this.msnLoginButton = (ImageButton) findViewById(R.id.msn_login_btn);
		this.msnLoginButton.setOnClickListener(this);
		this.loginStatus = (TextView) findViewById(R.id.main_page_login_status);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main_page, menu);
		return true;
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		Log.i(TAG, "onResume()");
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Intent intent = null;
		switch (v.getId()) {
		case R.id.facebook_login_btn:
			Toast.makeText(this, "Facebook login", Toast.LENGTH_LONG).show();
			intent = new Intent(this, LoginActivity.class);
			intent.putExtra("login", FACEBOOK_LOGIN);
			startActivity(intent);
			break;
		case R.id.google_login_btn:
			Toast.makeText(this, "Google login", Toast.LENGTH_LONG).show();
			intent = new Intent(this, LoginActivity.class);
			intent.putExtra("login", GOOGLE_LOGIN);
			startActivity(intent);
			break;
		case R.id.msn_login_btn:
			Toast.makeText(this, "MSN login", Toast.LENGTH_LONG).show();
			intent = new Intent(this, LoginActivity.class);
			intent.putExtra("login", MSN_LOGIN);
			startActivity(intent);
			break;
		case R.id.yahoo_login_btn:
			Toast.makeText(this, "Yahoo login", Toast.LENGTH_LONG).show();
			intent = new Intent(this, LoginActivity.class);
			intent.putExtra("login", YAHOO_LOGIN);
			startActivity(intent);
			break;
		}
	}

	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		Constants.CLIENT_LOGIN_STATUS = false;
		super.onBackPressed();
	}
}
